package thread;

import java.util.Scanner;

/**
 * @Author liangzai
 * @Description:
 */
public class Demo1 {
    public static void main(String[] args) {
        Object locker = new Object();
        Thread t1 = new Thread(()->{
            synchronized (locker){
                try {
                    System.out.println("t1开始!");
                    locker.wait();
                    System.out.println("t1结束!");
                } catch (InterruptedException e) {
                    throw new RuntimeException();
                }
            }
        });
        Thread t2 = new Thread(()->{
            Scanner scanner = new Scanner(System.in);
            System.out.println("输入 结束t1wait!");
            scanner.next();
            synchronized (locker){
                locker.notify();
            }
        });

        t1.start();
        t2.start();
    }
}
